import matplotlib.pyplot as plt
from utils.tools import draw_range
# Precision Recall Curve data
pr_data = {
    "DSH":[[0.81, 0.814012, 0.816008, 0.81601, 0.8149735, 0.8143604, 0.8128086666666665, 0.8098634285714286, 0.80473675, 0.7959662222222222, 0.7827613999999999, 0.7625076363636363, 0.7335305000000001, 0.6998595384615385, 0.664759, 0.6307964, 0.5995858749999999, 0.5714521176470588, 0.5461027777777777, 0.522696, 0.5013992],[0.00013728813632042148, 0.06898406803757826, 0.13830644117679913, 0.2074601699397317, 0.2762622046364704, 0.3450679664651252, 0.4132925445264118, 0.4804274582268117, 0.5455842388284509, 0.6070928790787002, 0.6633571192189119, 0.7108122026110067, 0.7459632221902721, 0.7710316968620755, 0.7886971162101254, 0.8018598297536373, 0.8129977969732135, 0.8232784752226434, 0.8330381339904852, 0.8416291532940231, 0.8498291537892073]],
    "DHN":[[0.839, 0.849468, 0.8514860000000001, 0.8405240000000002, 0.8343605, 0.8370696000000001, 0.8392446666666667, 0.8354674285714285, 0.83218625, 0.8243837777777778, 0.8127323999999999, 0.7927767272727273, 0.761814, 0.7239244615384615, 0.6827564285714286, 0.6430345333333334, 0.60714475, 0.5748256470588236, 0.5459187777777778, 0.5198598947368421, 0.4961865],[0.0001422033905837452, 0.07198881384558627, 0.14431966169680527, 0.2136925422525237, 0.28283406919446136, 0.35469050898043497, 0.4267345762039185, 0.4956162731976656, 0.564194067672157, 0.6287672909194516, 0.6887562758619606, 0.7390291553277056, 0.774726107966475, 0.7975438968997914, 0.8100499978768639, 0.8174167732952629, 0.8232471120387781, 0.8281386428666301, 0.8327574542392977, 0.8370625406920444, 0.8409940633780789]],
    "DPSH":[[0.838, 0.8343379999999999, 0.8387530000000002, 0.8223926666666667, 0.8201379999999999, 0.8226644, 0.8213289999999999, 0.8219554285714286, 0.821112, 0.8125695555555557, 0.800051, 0.7788192727272726, 0.7485328333333333, 0.7104849230769231, 0.6709348571428573, 0.634856, 0.601146125, 0.5706954117647058, 0.5433703333333333, 0.5184051578947368, 0.4955348],[0.00014203389905742368, 0.07070661017150269, 0.1421615271648625, 0.20908288024752983, 0.2780128827472363, 0.3485866141458682, 0.41762491324965956, 0.4876006793684937, 0.5566861037569324, 0.6197564426023164, 0.6780093173369969, 0.7260179712197278, 0.7612198311310494, 0.7827376200526487, 0.7960244078382384, 0.8070203432738781, 0.8151133917556145, 0.82218831134215, 0.8288700047954917, 0.834720172971487, 0.8398894936996512]],
}

markers = "DdsPvo*xH1234h"
method2marker = {}
i = 0
for method in pr_data:
    method2marker[method] = markers[i]
    i += 1

plt.figure(figsize=(20, 5))
plt.subplot(131)
for method in pr_data:
    P, R = pr_data[method]
    plt.plot(R, P, linestyle="-", marker=method2marker[method], label=method)
plt.grid(True)
plt.xlim(0, 1)
plt.ylim(0, 1)
plt.xlabel('recall')
plt.ylabel('precision')
plt.legend()

plt.subplot(132)
for method in pr_data:
    P, R = pr_data[method]
    plt.plot(draw_range, R, linestyle="-", marker=method2marker[method], label=method)
plt.xlim(0, max(draw_range))
plt.grid(True)
plt.xlabel('The number of retrieved samples')
plt.ylabel('recall')
plt.legend()

plt.subplot(133)
for method in pr_data:
    P, R = pr_data[method]
    plt.plot(draw_range, P, linestyle="-", marker=method2marker[method], label=method)
plt.xlim(0, max(draw_range))
plt.grid(True)
plt.xlabel('The number of retrieved samples')
plt.ylabel('precision')
plt.legend()
plt.savefig("pr.png")
plt.show()
